<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<style>
   #father{
       width: 200px;
       height: 200px;
       background: black;
       padding: 10px;
   }
   #child{
       width: 100px;
       height: 100px;
       background: greenyellow;
   }
</style>

<body>
    <div id="father">
        <div id="child"></div>
    </div>

    <script>
      //先父,后子。事件触发顺序变更为*自外向内*，这就是事件捕获；
      /* 2.创建两个div，一个大一些，一个小一些 */
      document.getElementById("father").addEventListener("click",function(){
          alert("父级："+ this.id);
      },true);

      document.getElementById("child").addEventListener("click",function(){
          alert("子级："+ this.id);
      },true);
    </script>
</body>
</html>